package xyz.zq.dockerdemo.controller;

import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import xyz.zq.dockerdemo.entity.DockerUser;
import xyz.zq.dockerdemo.service.DockerUserService;

import java.util.List;

/**
 * @author hzq
 * @date 2021/11/9 15:39
 */
@RestController
@RequestMapping("/dockerUser")
@AllArgsConstructor
public class DockerUserController {

    private final DockerUserService dockerUserService;

    @PostMapping
    public Boolean add(@RequestBody DockerUser dockerUser) {
        return dockerUserService.save(dockerUser);
    }

    @PutMapping
    public Boolean edit(@RequestBody DockerUser dockerUser) {
        return dockerUserService.updateById(dockerUser);
    }

    @DeleteMapping("/{id}")
    public Boolean del(@PathVariable Integer id) {
        return dockerUserService.removeById(id);
    }

    @GetMapping("/{id}")
    public DockerUser get(@PathVariable Integer id) {
        return dockerUserService.getById(id);
    }

    @GetMapping
    public List<DockerUser> list() {
        return dockerUserService.list();
    }
}
